#include "glwindow.h"

GLWindow::GLWindow()
{

}

void GLWindow::initializeGL()
{
    QGLFormat *  qglformat = new QGLFormat();
    qglformat->setVersion(3, 1);
    QGLFormat::setDefaultFormat(*qglformat);

    Application::Init();

    GLSLProgram::New("Default", new Shader(GL_FRAGMENT_SHADER,"basique.frag"), new Shader(GL_VERTEX_SHADER,"basique_2D.vert"));

    //	Here I create a New entity, wich would automaticaly be added to Entity::Entities

    Entity::New( Mesh::NewRect(1.0, 1.0));

     Entity::Last().m_Mesh->m_Image = Image("mov.png");
        Entity::Last().m_Mesh->m_Image.GenTexture();

    View * view = new View();
    view->m_GLSLProgram=GLSLProgram::Find("Default");
    Entity::Last().m_GLSLProgram = GLSLProgram::Find("Default");
    Entity::Entities.push_back(view);

}

void GLWindow::paintGL()
{

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    Application::UpdateDisplay();
}

void GLWindow::resizeGL(int w, int h)
{


}
